package com.unionftech.baselibrary.base

import android.content.Context
import android.content.pm.ApplicationInfo
import androidx.multidex.MultiDexApplication

open class BaseApplication : MultiDexApplication() {

    companion object {
        lateinit var appContext: Context
    }

    /**
     * 程序创建的时候执行
     */
    override fun onCreate() {
        super.onCreate()
        appContext = this
        AppCrashHandler.getInstance().init(this)
    }

    /**
     * 程序在内存不足的时候执行
     */
    override fun onLowMemory() {
        super.onLowMemory()
    }

    /**
     * 程序在内存清理的时候执行
     */
    override fun onTrimMemory(level: Int) {
        super.onTrimMemory(level)
    }

    /**
     * 程序终止的时候执行
     */
    override fun onTerminate() {
        super.onTerminate()
    }

    fun isDebug(): Boolean {
        val info = applicationInfo
        return info.flags and ApplicationInfo.FLAG_DEBUGGABLE != 0
    }
}